
<template>
  <el-card style="margin-bottom: 5px">
    <el-input clearable @clear="load" style="width: 260px; margin-right: 5px;" v-model="data.shenhezhuangtai" placeholder="请输入分类名查询" :prefix-icon="Search"></el-input>
    <el-button type="primary" @click="load">查 询</el-button>
    <el-button type="info" @click="reset">重 置</el-button>
  </el-card>
  <el-card>
    <el-table :data="data.tableData" style="width: 100%" :header-cell-style="{ color:'#333',backgroundColor:'#dde8ff'}">
      <el-table-column width="100" prop="userName" label="上传人" />
      <el-table-column width="100" prop="shangpinName" label="商品分类" />
      <el-table-column width="100" prop="shangpingoumaishuliang" label="购买数量" />
      <el-table-column width="100" prop="shouhuoren" label="收货人" />
      <el-table-column width="100" prop="shoujihao" label="手机号" />
      <el-table-column width="100"  label="收货地址" >
        <template #default="scope">
          <span>{{ scope.row.shouhuosuozaidiqu + scope.row.shouhuoxiangxidizhi }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="shenheneirong" label="审核内容" />
      <el-table-column width="100" prop="shenhezhuangtai" label="审核状态" />
      <el-table-column prop="shangchuanshijian" label="创建时间" />
      <el-table-column label="操作" width="100">
        <template #default="scope">
          <el-button type="primary" icon="Edit" circle @click="headleEdit(scope.row)" ></el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
<!--分页-->
  <el-card style="margin-bottom: 5px">
    <el-pagination
        v-model:current-page="data.pageNum"
        v-model:page-size="data.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :page-sizes="[5, 10, 15]"
        :total="data.total"
        @current-change="load"
        @size-change="load"
    />
  </el-card>

  <!-- 使用子组件 AdminDialog -->
  <Dialog
      v-model="data.formVisible"
      :form="data.form"
      @save="load"
  />
</template>

<script setup>import { Search } from "@element-plus/icons-vue";
import { reactive } from "vue";
import request from "@/utils/request";
import Dialog from "@/views/Dingdanguanli/Dialog.vue";

const data = reactive({
  formVisible: false,
  pageNum: 1,
  pageSize: 5,
  total: 0,
  tableData: [],
  form: {}
});

const load = () => {
  request.get('dingdanshenhe/selectPage', {
    params: {
      pageNum: data.pageNum,
      pageSize: data.pageSize,
    }
  }).then(res => {
    console.log(res.data);
    data.tableData = res.data.list;
    data.total = res.data.total;
  }).catch(err => {
    ElMessage.error(err);
  });
}

load()

// 重置按钮
const reset = () => {
  data.shenhezhuangtai = ''
  load()
}

// 修改按钮
const headleEdit = (row) => {
  console.log("编辑按钮点击");
  data.form = JSON.parse(JSON.stringify(row))
  console.log("编辑按钮点击",data.form);
  data.formVisible = true
}
</script>